#!/bin/bash

[ "$1" = "" ] && { echo -e "\nmust give dir-path to authorized_keys files, exiting ...\n"; exit 1;}

if [ -f $1/authorized_keys ]; then
	echo "error: file $1/authorized_keys exists."
	exit 1
fi

echo "Generating $1/authorized_keys file ..."
set -e
ssh-keygen -f $1/authorized_keys -t dsa -N ''
mv $1/authorized_keys $1/authorized_keys.priv
mv $1/authorized_keys.pub $1/authorized_keys
chmod 600 $1/authorized_keys
